package com.sykj.springboot.thread.AtomicInteger;

import com.sykj.springboot.common.utils.TimeUtils;

import java.util.concurrent.atomic.AtomicInteger;

public class SellerThred implements Runnable{

    private AtomicInteger count;
    private AtomicInteger totalCount;
    private String name;


    public SellerThred(String name,AtomicInteger count, AtomicInteger totalCount) {
        this.count = count;
        this.totalCount = totalCount;
        this.name = name;
    }


    @Override
    public void run() {

        while (count.intValue()>0){
            count.decrementAndGet();
            totalCount.incrementAndGet();
            System.out.println(TimeUtils.getCurrentDateTime()+":" +Thread.currentThread().getName()+"卖一张:剩余："+count+":卖出："+totalCount);
        }
    }
}
